package com.mall.b2c.bean;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import com.mall.b2c.domain.goods.GoodsDomain;
import com.mall.b2c.domain.order.OrderDomain;
import com.mall.b2c.domain.order.OrderItemDomain;
import com.mall.b2c.domain.order.RefundDomain;
import com.mall.b2c.domain.order.RefundLogDomain;
import com.mall.b2c.util.DictionaryUtils;
import com.mall.common.util.DateHelper;

public class RefundBean {
	private String refundNo;// 退款编号
	private String createDate;
	private String productName;// 商品名称
	private String refundStatus;// 退款状态
	private Boolean isChange;//是否换货
	private BigDecimal amount;// 退款金额
	private String remark;// 备注
	private String orderNo;// 订单编号
	private String goodsPath;
	private String consignee; //收货人
	private String areaName; //收货人地区
	private String address;// 收货人地址
	private String contact;// 收货人联系方式
	private Integer step;//步骤
	
	private String logisticsNo;//快递单号
	private String deliveryMethodName;//配送方式
	private BigDecimal shipFee;//快递费
	private List<RefundLogBean> logs;

	public RefundBean(OrderItemDomain orderItem) {
		super();
		RefundDomain refund = orderItem.getRefund();
		if(refund != null){
			this.refundNo = refund.getRefundNo();
			this.createDate = DateHelper.date2String(refund.getCreateDate(), "yyyy-MM-dd HH:mm:ss");
			this.productName = refund.getProductName();
			this.refundStatus = DictionaryUtils.getEnumName(refund.getRefundStatus());
			this.isChange = refund.getIsChange();
			this.amount = refund.getSubtotal();
			this.remark = refund.getRemark();
		}
		OrderDomain order = orderItem.getOrder();
		if(order != null){
			this.orderNo = order.getOrderNo();
		}
		GoodsDomain goods = orderItem.getGoods();
		if(goods != null){
			this.goodsPath = goods.getPath();
		}
	}

	public RefundBean(RefundDomain refund) {
		this.refundNo = refund.getRefundNo();
		this.createDate = DateHelper.date2String(refund.getCreateDate(), "yyyy-MM-dd HH:mm:ss");
		this.productName = refund.getProductName();
		this.refundStatus = DictionaryUtils.getEnumName(refund.getRefundStatus());
		this.isChange = refund.getIsChange();
		this.amount = refund.getSubtotal();
		this.remark = refund.getRemark();
		if(this.isChange){
			this.consignee = refund.getConsignee();
			this.areaName = refund.getAreaName();
			this.address = refund.getAddress();
			this.contact = refund.getContact();
			this.deliveryMethodName = refund.getDeliveryMethodName();
			this.logisticsNo = refund.getLogisticsNo();
			this.shipFee = refund.getShipFee();
		}
		if(refund.getLogs() != null){
			logs = new ArrayList<RefundLogBean>();
			for(RefundLogDomain log : refund.getLogs()){
				logs.add(new RefundLogBean(log));
			}
		}
		this.step = refund.getRefundStatus().ordinal();
	}
	

	public String getRefundNo() {
		return refundNo;
	}

	public void setRefundNo(String refundNo) {
		this.refundNo = refundNo;
	}

	public String getRefundStatus() {
		return refundStatus;
	}

	public void setRefundStatus(String refundStatus) {
		this.refundStatus = refundStatus;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public String getCreateDate() {
		return createDate;
	}

	public void setCreateDate(String createDate) {
		this.createDate = createDate;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getGoodsPath() {
		return goodsPath;
	}

	public void setGoodsPath(String goodsPath) {
		this.goodsPath = goodsPath;
	}

	public Boolean getIsChange() {
		return isChange;
	}

	public void setIsChange(Boolean isChange) {
		this.isChange = isChange;
	}

	public String getConsignee() {
		return consignee;
	}

	public void setConsignee(String consignee) {
		this.consignee = consignee;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public List<RefundLogBean> getLogs() {
		return logs;
	}

	public void setLogs(List<RefundLogBean> logs) {
		this.logs = logs;
	}

	public Integer getStep() {
		return step;
	}

	public void setStep(Integer step) {
		this.step = step;
	}

	public String getLogisticsNo() {
		return logisticsNo;
	}

	public void setLogisticsNo(String logisticsNo) {
		this.logisticsNo = logisticsNo;
	}

	public String getDeliveryMethodName() {
		return deliveryMethodName;
	}

	public void setDeliveryMethodName(String deliveryMethodName) {
		this.deliveryMethodName = deliveryMethodName;
	}

	public BigDecimal getShipFee() {
		return shipFee;
	}

	public void setShipFee(BigDecimal shipFee) {
		this.shipFee = shipFee;
	}

}
